<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ page isELIgnored="false" %>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

<html>
<head>
    <link href="<s:url value="/resources"/>/css/style_new.css" rel="stylesheet" type="text/css" />
<link href="<s:url value="/resources"/>/css/main_new.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script>  
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
<style>
html,body {
	margin: 0;
	padding: 0;
	font-size: 85%;
}
</style>
<script >
    
     var qieye = 0;
$(function(){
	$("#yind").button();
    $("#chax").button(); 
    $("#excel").button();
	$("#excel").hide();
    $("#reset").button();
        
    loadTab(0);
    //queryNum();
    
    //日期控件处理
    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
 
	function loadTab(i){	
		if(i==0){
			loadBdxx(i);
		}else{
			
			loadYdxx(i);
		}
  		$("#myTab"+i).jqGrid('setGridHeight','300px');
  	}  
	

    $( "#tabs" ).tabs({
		    select: function(event, ui) {
		    var i =ui.index;	    
		    if(i==''){
		    i="0";
		    }
		    qieye = i;
		    loadTab(i);
		    //$("#myTab"+qieye).jqGrid('setGridParam',{url:'findVerifyHtxxList.action?index='+qieye,mtype:'post',page:1}).trigger("reloadGrid");
		   // alert("aa");
		    //jQuery("#myTab1").jqGrid('hideCol',["Verify"]);
		        
            //return false;
  		  }
		
	});
	
	
 });
  

	

  
  
  function loadBdxx(i){
      $("#myTab"+i).jqGrid({      
    url:'findweibmlist?index='+i,  
    datatype: 'json',
    mtype: 'post',         
   	colNames:['操作','报单编号' ,'煤种','品种','价格类型','价格','报单数量','竞价日期','maimlx'],
   	colModel:[ 
   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   	    {name:'baodbh',index:'baodbh', width:120},
   	 
   		{name:'meizmc',index:'meizmc', width:80 },	
   		{name:'pinzmc',index:'pinzmc', width:80 },
   	    {name:'jiaglxmc',index:'jiaglxmc', width:120 },
   		{name:'danj',index:'danj', width:100 },
   		{name:'shul',index:'shul', width:100 },
   		{name:'kaishshj',index:'kaishshj', width:75},
   		{name:'maimlx',index:'maimlx',   hidden:true }
   		
   	],
   
    jsonReader: {
           repeatitems : false, 
           id: 'baodbh'
         },    	
   	rowNum:10,

   	rowList:[10,20,30],     	
   	pager: '#pager'+i,   	
   	rownumbers: true,   	 
    viewrecords: true,
    //multiselect: sign,
    sortorder: 'desc',  
    altRows:true,  
	//caption: "报单列表",
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs'); 	
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j];	
			
			verify ="<a href='#' style='color:#f60' onclick='Verify("+ id +")'>报名</a>&nbsp;|&nbsp;<a href='#' style='color:#f60' onclick='Verify("+ id +")'>查看</a>";
					
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 	
  });
  }
 

  function loadYdxx(i){
      $("#myTab"+i).jqGrid({      
    url:'findweibmlist?index='+i,  
    datatype: 'json',
    mtype: 'post',         
   	colNames:['操作','报单编号' ,'煤种','品种','价格类型','价格','报单数量','竞价日期','maimlx'],
   	colModel:[ 
   	   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   	   	    {name:'baodbh',index:'baodbh', width:120},
   	   	 
   	   		{name:'meizmc',index:'meizmc', width:80 },	
   	   		{name:'pinzmc',index:'pinzmc', width:80 },
   	   	    {name:'jiaglxmc',index:'jiaglxmc', width:120 },
   	   		{name:'danj',index:'danj', width:100 },
   	   		{name:'shul',index:'shul', width:100 },
   	   		{name:'kaishshj',index:'kaishshj', width:75},
   	   		{name:'maimlx',index:'maimlx',   hidden:true }
   	],
   
    jsonReader: {
           repeatitems : false, 
           id: 'baodbh'
         },    	
   	rowNum:10,
   	rowList:[10,20,30],     	
   	pager: '#pager'+i,   	
   	rownumbers: true,   	 
    viewrecords: true,
    //multiselect: sign,
    sortorder: 'desc',  
    altRows:true,  
	//caption: "报单列表",
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs');
	
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j];	
			var rowData = jQuery("#myTab"+qieye).jqGrid("getRowData", id); 
			var czmc="拍卖";
			if (rowData.maimlx=='6'){
				czmc="拍卖";
				}else{
				czmc="招标";
				}
			verify ="<a href='#' style='color:#f60' onclick='select("+ id +")'>"+czmc+"</a>&nbsp;|<a href='#' style='color:#f60' onclick='selectYd("+ id +")'>编辑</a>";							
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 	
  });
  }
  
  
  function openwindow(url){
    var sheight = screen.height-70;
    var swidth = screen.width-10;
    var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
    var result=window.showModalDialog(url,window,winoption);
    if(result ==1){
     reloadYdxx(); 
     }
    return result;  
}
  
  function reloadYdxx(){
   window.location.href="<%=request.getContextPath()%>/jjjy/jjjylist";
}
  
   function Verify(id) { //单击修改链接的操作 
   if(id.id!=undefined){
	   var rowData = jQuery("#myTab0").jqGrid("getRowData", id.id);  
	   
		if (rowData.maimlx=='6'){
	       openwindow('<%=path %>/jjjy/jjbmMsr?bdbh='+id.id+'&lx=1');
		}else{
		   openwindow('<%=path %>/jjjy/jjbmCmr?bdbh='+id.id+'&lx=1');
		}
    }
}
  // 查询
function search(){   
  var formdata = $("#form1").serialize(); 
//alert(formdata); 
  $("#myTab"+qieye).jqGrid('setGridParam',{url:'findydbdlist?'+formdata+'&mmlx=6&index='+qieye,mtype:'post',page:1}).trigger("reloadGrid"); 
 
  //queryNum();
 
}

 function select(id) { //单击修改链接的操作 
	// var rowid = jQuery("#myTab"+qieye).jqGrid("getGridParam","selrow");
 

	 var rowData = jQuery("#myTab"+qieye).jqGrid("getRowData", id.id); 
	// alert(id.id);
	 window.location.href='<%=path %>/jjjy/jjInfo?bdbh='+id.id;
	// window.location.href="/mtjyqt/views/jjjy/jj/jj_detail.jsp";


 
}

 function selectYd(id) { //单击查询链接的操作 
	   if(id.id!=undefined){
		   var rowData = jQuery("#myTab1").jqGrid("getRowData", id.id);  
		   
			if (rowData.maimlx=='6'){
		       openwindow('<%=path %>/jjjy/jjbmMsr?bdbh='+id.id+'&lx=2');
			}else{
			   openwindow('<%=path %>/jjjy/jjbmCmr?bdbh='+id.id+'&lx=2');
			}
	    }
}


function queryNum(){   
  var formdata = $("#form1").serialize(); 
  $.post("<%=path%>/htgl/findVerifyHtxxListNum.action",formdata,function(data,textStatus)
  {
  
  var json = eval('(' + data + ')');

  var re=/(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
if (json[0].shul !="")
{
  // alert("价格范围："+json[0].jiag + "  总数量："+json[0].shul+"  总金额："+json[0].jine);
   $("#queryNum").html("价格范围："+json[0].jiag + "元/吨  总数量："+json[0].shul.toString().replace(re,"$1,")+"吨  总金额："+json[0].jine.toString().replace(re,"$1,")+"元");
 }
  });
  
}

function txt_onblur(i) {
            if (!event.srcElement.value) {
                event.srcElement.value = '0';
            }
           
            if (isNaN(temp)) {
                $("#"+i).val(0);                
            } 
        }
        
        //重置
			function resetSearch(){
			   $('#list_search  input[type=text]').val('');
			   $('#list_search select').val('-1');
			 }
        //导出excel
        function dc_excel(){ 
        var formdata = $("#form1").serialize(); 
	form1.action="<%=path%>/htgl/findVerifyHtxxList_excel.action?index="+qieye;
	form1.method = "post";
	form1.submit();
	}
	</script>

</head>

<body>
	<div class="container">
  <div class="containerbox">
   
    <div class="search mt10" id="list_search">
		<form id="form1" method="post">
			<table id="list_search" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td>报单编号:</td>
					<td><input type="text"  class="form-textbox" style="width: 200px;" name="aa" />
					</td>
					<td>煤种:</td>
					<td>
						<div class="select">
							<select name="bb"  class="form-textbox" style="width: 200px;">
								<option value="" selected>==请选择==</option>
								<c:forEach var="mz" items="${meiz}">
									<option value="${mz.diccode}">${mz.dicname}</option>
								</c:forEach>
							</select>
						</div>
					</td>
					<td>品种 :</td>
					<td>
						<div class="select">
							<select name="cc"  class="form-textbox" style="width: 200px;">
								<option value="" selected>==请选择==</option>
								<c:forEach var="pz" items="${pinz}">
									<option value="${pz.diccode}">${pz.dicname}</option>
								</c:forEach>
							</select>

						</div>
					</td>
				</tr>
 
				<tr>
					<td>报单日期:</td>
					<td><input id="datepicker" type="text"  class="form-textbox" style="width: 90px;"
						name="gg" /> -- <input id="datepicker1" type="text"
						 class="form-textbox" style="width: 90px;" name="hh" />
					</td>
					<td>价格:</td>
					<td><input id="jiag" type="text"  
						name="ii" onKeyUp="this.value=this.value.replace(/\D/g,'');"
						 class="form-textbox" style="width: 90px;"/> -- <input id="jiag1" type="text"
						 class="form-textbox" style="width: 90px;" name="jj"
						onKeyUp="this.value=this.value.replace(/\D/g,'');"
						  /></td>
					<td>数量:</td>
					<td><input id="shul" type="text"  class="form-textbox" style="width: 90px;"
						name="pp" onKeyUp="this.value=this.value.replace(/\D/g,'');"
						 /> -- <input id="shul1" type="text"
						 class="form-textbox" style="width: 90px;" name="qq"
						onKeyUp="this.value=this.value.replace(/\D/g,'');"/>
					</td>
				</tr>
				<tr>
					<td>局、发站:</td>
					<td><input type="text"  class="form-textbox" style="width: 200px;" name="mm" />
						 
					</td>
					<td>局、到站:</td>
					<td><input type="text"  class="form-textbox" style="width: 200px;" name="nn" />
					</td>
					<td>交收方式:</td>
					<td>
						<div class="select">
							<select name="dd"  class="form-textbox" style="width: 200px;">
								<option value="" selected>==请选择==</option>
								<c:forEach var="hy" items="${hangy}">
									<option value="${hy.diccode}">${hy.dicname}</option>
								</c:forEach>
							</select>

						</div>
					</td>
				</tr>

				 
  <tr>
    <td align="right" class="pr10 search-table-70">&nbsp;</td>
    <td align="left"><input name="" type="button" class="form-button-query form-button" value="查询" onclick="search();"/>
    <input name="" type="button" class="form-button-reset form-button" value="重置"  onclick="resetSearch();"/></td>
  </tr>				
			</table>
		</form>

		<div id="tabs">
			<ul>
				<li><a href="#tabs-0">未报名</a></li>
				<li><a href="#tabs-1">已报名</a></li>
				<li id="queryNum"  style="float:right; vertical-align: bottom; line-height:20px; top: 3px;"></li>
			</ul>
			<div id="tabs-0">
				<table id="myTab0" class="scroll" cellpadding="0" cellspacing="0"  ></table>
				<div id="pager0" class="scroll"></div>
				<div id="message0" class="scroll"></div>
			</div>
			<div id="tabs-1">
				<table id="myTab1" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager1" class="scroll"></div>
				<div id="message1" class="scroll"></div>
			</div>
</div>
		</div>
</div>
		<div id="dialog-confirm" title="是否确认？"></div>
</body>
</html>
